The PhysicalPieceObserver script is a script that can be added onto GameObjects that you would like physical pieces to pair with and control the movement of.

The PhysicalPieceObserver script requires the Gameboard GameObject to be present. Find the Gameboard menu at the top of the unity header and click "Add SDK" to add the Gameboard GameObject to your project. If you do not have the Gameboard menu options, see Gameboard SDK Access

Step-by-Step

First, select all the GameObjects you would like to attach the PhysicalPieceObserver script to.

Next, find the Gameboard menu at the top of the unity header and click "Add Physical Piece Observer" to add the PhysicalPieceObserver to your GameObject(s).

Step-by-Step

This will add a the script to the gameobjects, and you will see a red gizmo indicating the pairing radius, and what on the gameobject is considered "forward".

Step-by-Step

Now that GameObject is able to quickly be paired with physical gameboard tokens!

You will notice the Physical Piece Observer Script has a few customizable options.

Step-by-Step

Property Descriptions

Standard Options

World View Options

If the game object is in the world space, as opposed to the child of a canvas, you will want to set these options as well.

Other Options

There are various events that you can use to keep track of physical token pairing and paired token locations:

OnPieceAvailableForPairing

Properties: GameboardShape piece, bool tokenAlreadyPaired, bool currentlyPairedToToken

OnPieceAutoPairingDenied

Properties: GameboardShape piece, List reasons

OnPiecePaired

Properties: GameboardShape piece

OnPieceUnpaired

Properties: GameboardShape piece

OnPieceTransformChanged

Properties: GameboardShape piece

You can manually pair or unpair tokens as well.

To pair a GameboardShape, you can call pairPiece with an optional flag to overridePairing. Say you get a GameboardShape from the OnPieceAvailableForPairing event, and you decide you do want to pair this GameObject with that physical GameboardShape. And you notice that token is already paired, but you displayed an alert asking if the user wants to continue and they clicked yes, so you want to proceed with the pairing.

objPieceObserver.pairPiece(shape, true);

and to remove a pairing simple call unpairPiece on the piece observer.

objPieceObserver.unpairPiece();

You can also see all the paired pieces by shapeId on the TouchController in the pairedPieces dictionary. This pairs the GameboardShape based on their shapeId to the PhyscialPieceObserver they are currently paired with.